package cn.sitedev.simplefactory;

import cn.sitedev.payment.*;

/**
 * 支付方式工厂
 *
 * @author qchen
 * @date 2020/9/16 12:34
 */
public class PaymentFactory {
    public static final String PAY_TYPE_ALIPAY = "alipay";
    public static final String PAY_TYPE_CROSS_BORDER = "crossBorder";
    public static final String PAY_TYPE_UNIONPAY = "unionPay";
    public static final String PAY_TYPE_WECHAT = "wechat";

    public Payment createPayment(String payType) {
        Payment payment = null;
        switch (payType) {
            case PAY_TYPE_ALIPAY:
                payment = new AlipayPayment();
                break;
            case PAY_TYPE_CROSS_BORDER:
                payment = new CrossBorderPayment();
                break;
            case PAY_TYPE_UNIONPAY:
                payment = new UnionPayPayment();
                break;
            case PAY_TYPE_WECHAT:
                payment = new WechatPayment();
                break;
            default:
                payment = new AlipayPayment();
                break;
        }
        return payment;
    }
}
